<template>
    <a-row>
        <a-col :xs='24' :sm='24' :md='24' :lg='24' :xl='24' :xxl='24'>
            <!-- <div style="margin:0 0 1em 0 ">
                <a-tooltip placement='bottom' style="margin-left:1em ">
                    <template slot='title'>
                        <span>{{$t('Create')}}</span>
                    </template>
                    <a-button type="primary" icon='file-add' @click="create = true"></a-button>
                </a-tooltip>

                <a-tooltip placement='bottom'>
                    <template slot='title'>
                        <span>{{$t('Delete')}}</span>
                    </template>
                    <a-button type='danger' style="margin-left:1em" icon='close-circle' @click="openmodal('del')"></a-button>
                </a-tooltip>
            </div> 
            <a-table class="tabsmall" :columns='secretcolumns' :dataSource='secretdata' :pagination='pagination' size='small' :rowSelection='{type:"radio",selectedRowKeys:selectedRowKeys,onChange:onSelectChange}'></a-table>-->
            <a-table class="tabsmall" :columns='secretcolumns' :dataSource='secretdata' :pagination='pagination' size='small' :locale="defaultSetting"></a-table>
        </a-col>

    </a-row>
</template>
<script>
import EmptyData from '@/components/common/EmptyData'
export default {
    name:'bucket',
    props:['tarname'],
    components: { EmptyData },
    data(){
        return{
            secretcolumns:[
                {title:this.$t('User')+this.$t('Name'),dataIndex:'user',key:'user',sorter:(a,b)=>a.user.length - b.user.length},
                {title:this.$t('Type'),dataIndex:'type',key:'type'},
                {title:this.$t('Access-key'),dataIndex:'access_key',key:'access_key'},
                {title:this.$t('Secret-key'),dataIndex:'secret_key',key:'secret_key'},
            ],
            pagination:{
                defaultPageSize:5,
                showTotal: total => `${this.$t('A-total-of')} ${total} ${this.$t('Data')}`,
                showSizeChanger:true,
                pageSizeOptions: ['5', '15', '20', '25'],
                onShowSizeChange:(current, pageSize)=>this.pageSize = pageSizev,
                buildOptionText: (props) => `${props.value} / ${this.$t('page')}`
            },
            secretdata:[
                // {key:'0',name:'asdas',type:'active',access:'nceph2',secret:'Reqs:0/s'}
            ],
            defaultSetting: {emptyText:<EmptyData />}
            // selectedRowKeys:[],
            // onrecord:''

        }
    },
    computed:{
        getlanguage(){
            return this.$store.state.language
        }
    },
    watch:{
        tarname(val){
            let s3Keys = val.keys.length!=0? [...val.keys] : [];
            let swiftKeys = val.swift_keys.length!=0? [...val.swift_keys] : [];
            if(s3Keys.length != 0) {
                s3Keys.map(item => {
                    item.type = 's3'
                });
            }
            if(swiftKeys.length !=0) {
                swiftKeys.map(item => {
                    item.type = 'swift'
                });
            }
            this.secretdata = s3Keys.concat(swiftKeys)
            // this.secretdata = val.keys.concat(val.swift_keys)
        },
        getlanguage(val){
            this.secretcolumns=[
                {title:this.$t('User')+this.$t('Name'),dataIndex:'user',key:'user',sorter:(a,b)=>a.user.length - b.user.length},
                {title:this.$t('Type'),dataIndex:'type',key:'type'},
                {title:this.$t('Access-key'),dataIndex:'access_key',key:'access_key'},
                {title:this.$t('Secret-key'),dataIndex:'secret_key',key:'secret_key'},
            ]
        }
    },
    // methods:{
    //     onSelectChange (selectedRowKeys) {
    //         console.log(selectedRowKeys);
    //         for(var i=0;i<this.secretdata.length;i++){
    //             if(selectedRowKeys == i){
    //                 this.onrecord = this.secretdata[i]
    //             }
    //         }
    //         console.log(this.onrecord,'one')
	//         this.selectedRowKeys = selectedRowKeys
    //     },
    //     openmodal(name){
    //         if(this.selectedRowKeys.length!=0){
	// 	        if(name == 'del'){
	// 	        	this.del()
	// 	        }
	// 	    }
	//         else{
	//           this.$notification['error']({
	//             message:'请选择操作对象'
	//           })
	//         }
	//     },
	//     del(){
    //         let _this = this
	//     	this.$confirm({
    //             title: this.$t('Delete')+this.$t('User'),
    //             content:'你确定删除该用户密钥吗？',
    //             cancelText:this.$t('Cancel'),
	//              okText:this.$t('Sure'),
    //             okType:'danger',
    //             onOk(){
    //                 // _this.$axios.delete(_this.allurl+'rgw/user/s3',{
    //                 //     data:{
    //                 //         name:_this.target
    //                 //     }
    //                 // }).then(res=>{
    //                 //     console.log(res.data)
    //                 // })
    //             },
    //             onCancel(){
    //             }
    //         })
	//     },
    // },
    mounted(){
    }
}
</script>
